Conversation
Greptile SummaryThis PR introduces promise-level deduplication for the Key changes:
Confidence Score: 5/5Safe to merge — the change is a clean promise-deduplication optimization with correct error-eviction semantics and no behavioral regressions. No P0 or P1 issues found. The new cache correctly shares in-flight and resolved promises, the .catch() eviction prevents stale rejected entries, the highlighterOptionsByKey invariant is preserved, and the bounded key space (appearance × language) prevents unbounded cache growth. All edge cases (concurrent miss, concurrent hit before rejection, post-rejection retry) behave as intended. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant C1 as Caller A
participant C2 as Caller B (concurrent)
participant P as prepareHighlighter
participant Cache as highlighterPromiseCache
participant SH as getSharedHighlighter
C1->>P: prepareHighlighter(lang, appearance)
P->>Cache: get(cacheKey) → miss
P->>SH: getSharedHighlighter(options)
SH-->>P: Promise<Highlighter> (pending)
P->>Cache: set(cacheKey, promise)
P-->>C1: promise (pending)
C2->>P: prepareHighlighter(lang, appearance)
P->>Cache: get(cacheKey) → hit
P-->>C2: same promise (pending)
SH-->>C1: resolves → Highlighter
SH-->>C2: resolves → Highlighter (shared)
Note over Cache: Entry stays for future callers
rect rgb(255, 220, 220)
Note over SH,Cache: On failure path
SH-->>P: rejects
P->>Cache: delete(cacheKey)
P-->>C1: rethrows error
P-->>C2: rethrows error (same promise)
Note over Cache: Entry cleared — next caller retries cleanly
end
Reviews (1): Last reviewed commit: "perf: cache highlighter promises by key" | Re-trigger Greptile |
Summary
${appearance}:${language}insrc/ui/diff/pierre.tsgetSharedHighlighter()promiseTesting
bun run typecheckbun testbun test test/pierre.test.tsThis PR description was generated by Pi using OpenAI GPT-5